﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using JF.RealtimeNotifications.Notifiers;
using JF.RealtimeNotifications.Notifiers.Realtime;
using System.Threading;

namespace JF.RealtimeNotifications.Test.Notifiers
{
    [TestClass]
    public class Realtime
    {
        [TestMethod]
        public void ConnectTest()
        {
            //TODO: Make this async test

            var messageTest = "MessageTest";

            RealtimeNotifier realtimeNotifier = (RealtimeNotifier)NotifierFactory.CreateNotifier<RealtimeNotifier>();

            realtimeNotifier.ApplicationKey = "Ugrahe";
            realtimeNotifier.AuthenticationToken = "ConnectTest";
            realtimeNotifier.PluginsDirectory = @"D:\Personal\Dev\CodePlex\RealtimeNotifications\JF.RealtimeNotifications\JF.RealtimeNotifications.Test.Notifiers\Providers\Plugins";
            
            realtimeNotifier.Connect(null);

            realtimeNotifier.Subscribe(new RealtimeNotification("ConnectTest", String.Empty), (notification) => 
            {
                Assert.AreEqual(messageTest, notification.Text);
            });

            realtimeNotifier.Publish(new RealtimeNotification("ConnectTest", messageTest));
        }
    }
}
